﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace HA.MT3DMS.DomainLayer
{
    [Serializable]
    public class MTSpecies:ICloneable 
    {

        public MTSpecies(string name, bool speiesMoblie)
        {
            this._name = name;
            this._SpeiesMoblie = speiesMoblie;
            this._initConc = new List<double[,]>();
        }

        public MTSpecies(int nRow,int nCol,int nLayer)
        {

            this._rowCount = nRow;
            this._colCount = nCol;
            this._layerCount = nLayer;

            this._initConc = new List<double[,]>();
            for (int i = 0; i < nLayer; i++)
            {
                this._initConc.Add(new double[nRow, nCol]);
            }

        }

        public MTSpecies(string name, bool speiesMoblie,int nRows,int nCols,int nLayers):this(nRows,nCols,nLayers)
        {
            this._name = name;
            this._SpeiesMoblie = speiesMoblie;
            this._initConc = new List<double[,]>();
            for (int i = 0; i < nLayers; i++)
            {
                this._initConc.Add(new double[nRows, nCols]);
            }
        }

        int _rowCount;

        public int RowCount
        {
            get { return _rowCount; }
            set { _rowCount = value; }
        }
        int _colCount;

        public int ColCount
        {
            get { return _colCount; }
            set { _colCount = value; }
        }

        int _layerCount;

        public int LayerCount
        {
            get { return _layerCount; }
            set { _layerCount = value; }
        }



        string _name;

        public string Name
        {
            get { return _name; }
            set { _name = value; }
        }


        List<double[,]> _initConc;

        public List<double[,]> InitConc
        {
            get { return _initConc; }
          

        }

        bool _SpeiesMoblie;

        public bool SpeiesMoblie
        {
            get { return _SpeiesMoblie; }
            set { _SpeiesMoblie = value; }
        }


        public void SetInitConc(List<double[,]> initConc)
        {
            this.InitConc.Clear();
            this.InitConc.AddRange(initConc);

        }

        public void ResetGrid(int nRow, int nCol, int nLayer)
        {
            this._rowCount = nRow;
            this._colCount = nCol;
            this._layerCount = nLayer;


            this._initConc.Clear();

            for (int i = 0; i < _layerCount; i++)
            {
                this._initConc.Add(new double[_rowCount, _colCount]);
            }

        }

        public object Clone()
        {
            MTSpecies sp = (MTSpecies)this.MemberwiseClone();
            sp._initConc = new List<double[,]>();
            foreach (double[,] item in this._initConc)
            {
                sp._initConc.Add((double[,])item.Clone ());
                
            }

            return sp;
            
        }


    }
}
